package org.example.socket;

import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class UDPSocket2 {
    public static void main(String[] args) throws Exception {
        DatagramSocket socket = new DatagramSocket(3307);
        byte[] b = new byte[1024];
        DatagramPacket packet = new DatagramPacket(b,0, b.length);
        System.out.println("开始监听");
        socket.receive(packet);
        byte[] data = packet.getData();
        System.out.println("接收到信息：" + new String(data,0,packet.getLength()));
    }
}
